package test;

import java.util.Arrays;

public class goods {
    public static void main(String[] args) {
        int[] arr = {8,4,2,5};
        Arrays.sort(arr);
        int max = 0;
        int cur = 0;
        for (int i = arr.length-1; i >=0 ; i--) {
            cur = arr[i];
            for (int j = i-1; j >=0 ; j--) {
                if (cur + arr[j] <=12){
                    cur += arr[j];
                    max = Math.max(cur,max);
                }
            }
        }
        System.out.println(max);
    }
}
